home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / xpaint-2.1.1 / Paint.h < prev    next >
C/C++ Source or Header  |  1995-05-03  |  6KB  |  204 lines

  1. #ifndef _Paint_h
  2. #define _Paint_h
  3.  
  4. /* +-------------------------------------------------------------------+ */
  5. /* | Copyright 1992, 1993, David Koblas (koblas@netcom.com)            | */
  6. /* |                                                                   | */
  7. /* | Permission to use, copy, modify, and to distribute this software  | */
  8. /* | and its documentation for any purpose is hereby granted without   | */
  9. /* | fee, provided that the above copyright notice appear in all       | */
  10. /* | copies and that both that copyright notice and this permission    | */
  11. /* | notice appear in supporting documentation.  There is no           | */
  12. /* | representations about the suitability of this software for        | */
  13. /* | any purpose.  this software is provided "as is" without express   | */
  14. /* | or implied warranty.                                              | */
  15. /* |                                                                   | */
  16. /* +-------------------------------------------------------------------+ */
  17.  
  18. /****************************************************************
  19.  *
  20.  * Paint widget
  21.  *
  22.  ****************************************************************/
  23.  
  24. /* Resources:
  25.  
  26.  Name             Class        RepType        Default Value
  27.  ----             -----        -------        -------------
  28.  background         Background        Pixel        XtDefaultBackground
  29.  border             BorderColor    Pixel        XtDefaultForeground
  30.  borderWidth         BorderWidth    Dimension    1
  31.  destroyCallback     Callback        Pointer        NULL
  32.  height             Height        Dimension    0
  33.  mappedWhenManaged   MappedWhenManaged    Boolean        True
  34.  sensitive         Sensitive        Boolean        True
  35.  width             Width        Dimension    0
  36.  x             Position        Position    0
  37.  y             Position        Position    0
  38.  
  39. */
  40.  
  41. /* define any special resource names here that are not in <X11/StringDefs.h> */
  42.  
  43. #define XtNpaintResource "paintResource"
  44. #define XtNpattern     "pattern"
  45. #define XtNgrid          "grid"
  46. #define XtNsnap          "snap"
  47. #define XtNsnapOn      "snapOn"
  48. #define XtNlineWidth     "lineWidth"
  49. #define XtNfatBack     "fatBack"
  50. #define XtNsizeChanged     "sizeChanged"
  51. #define XtNundoSize     "undoSize"
  52. #define XtNzoom          "zoom"
  53. #define XtNpaint     "paint"
  54. #define XtNzoomX     "zoomX"
  55. #define XtNzoomY     "zoomY"
  56. #define XtNdrawWidth     "drawWidth"
  57. #define XtNdrawHeight     "drawHeight"
  58. #define XtNcompress     "compress"
  59. #define XtNdirty     "dirty"
  60. #define XtNfillRule     "fillRule"
  61. #define XtNregionCallback    "regionSetCallback"
  62. #define XtNdownX    "downX"
  63. #define XtNdownY    "downY"
  64. #define XtNlineForeground    "lineForeground"
  65. #define XtNlinePattern        "linePattern"
  66. #define XtNlineFillRule        "lineFillRule"
  67. #ifndef XtNreadOnly
  68. #define XtNreadOnly     "readOnly"
  69. #endif
  70. #ifndef XtNcursor
  71. #define XtNcursor     "cursor"
  72. #endif
  73.  
  74. #define XtCPaintResource "PaintResource"
  75. #define XtCPattern     "Pattern"
  76. #define XtCGrid         "Grid"
  77. #define XtCSnap         "Snap"
  78. #define XtCSnapOn     "SnapOn"
  79. #define XtCLineWidth     "LineWidth"
  80. #define XtCFatBack     "FatBack"
  81. #define XtCSizeChanged     "SizeChanged"
  82. #define XtCUndoSize     "UndoSize"
  83. #define XtCZoom           "Zoom"
  84. #define XtCPaint     "Paint"
  85. #define XtCZoomX     "ZoomX"
  86. #define XtCZoomY     "ZoomY"
  87. #define XtCDrawWidth     "DrawWidth"
  88. #define XtCDrawHeight     "DrawHeight"
  89. #define XtCCompress     "Compress"
  90. #define XtCDirty     "Dirty"
  91. #define XtCFillRule     "FillRule"
  92. #define XtCRegionCallback    "RegionSetCallback"
  93. #define XtCDownX    "DownX"
  94. #define XtCDownY    "DownY"
  95. #define XtCLineForeground    "LineForeground"
  96. #define XtCLinePattern        "LinePattern"
  97. #define XtCLineFillRule        "LineFillRule"
  98. #ifndef XtCReadOnly
  99. #define XtCReadOnly     "ReadOnly"
  100. #endif
  101.  
  102. /* declare specific PaintWidget class and instance datatypes */
  103.  
  104. typedef struct _PaintClassRec*        PaintClass;
  105. typedef struct _PaintRec*        PaintWidget;
  106.  
  107. /* declare the class constant */
  108.  
  109. extern WidgetClass paintWidgetClass;
  110.  
  111. /*
  112. **  Operation callback information
  113. */
  114. typedef enum    { opPixmap = 0x01, opWindow = 0x02 } OpSurface;
  115.  
  116. typedef struct {
  117.     int        refCount;
  118.     OpSurface    surface;
  119.     Drawable    drawable;
  120.     GC        first_gc, second_gc, base_gc;
  121.     void        *data;
  122.     int        isFat;
  123.     int        x, y;
  124.     int        realX, realY;
  125.     int        zoom;
  126.     Pixmap        base;
  127. } OpInfo;
  128.  
  129. typedef float    pwMatrix[2][2];
  130.  
  131. typedef void (*OpEventProc)(Widget, void *, XEvent *, OpInfo *);
  132. void OpRemoveEventHandler(Widget, int, int, Boolean, OpEventProc, void *);
  133. void OpAddEventHandler(Widget, int, int, Boolean, OpEventProc, void *);
  134. void UndoStart(Widget, OpInfo *);
  135. void UndoStartRectangle(Widget, OpInfo *, XRectangle *);
  136. void UndoStartPoint(Widget, OpInfo *, int, int);
  137. void UndoSetRectangle(Widget, XRectangle *);
  138. void UndoGrow(Widget, int, int);
  139.  
  140. Pixmap    PwUndoStart(Widget, XRectangle*);
  141. void    PwUndoSetRectangle(Widget, XRectangle*);
  142. void    PwUndoAddRectangle(Widget, XRectangle*);
  143. void    UndoSwap(Widget);
  144.  
  145. #define PwZoomParent    ((int)-5)
  146.  
  147. /*
  148. **  Public functions
  149. */
  150.  
  151. void PwUpdateFromLast(Widget, XRectangle *);
  152. void PwUpdate(Widget, XRectangle *, Boolean);
  153. void PwUpdateDrawable(Widget, Drawable, XRectangle *);
  154. void PwSetDrawn(Widget, Boolean);
  155. void PwGetPixmap(Widget, Pixmap *, int *, int *);
  156. void PwPutPixmap(Widget w, Pixmap pix);
  157. XRectangle *PwScaleRectangle(Widget, XRectangle *);
  158.  
  159. /*  Convenice routine (with caching) to get an XImage of an area */
  160. XImage *PwGetImage(Widget, XRectangle *);
  161.  
  162. /*
  163. **  Region routines
  164. */
  165.  
  166. /*  Set the region pixmap, and mask */
  167. void PwRegionSet(Widget, XRectangle *, Pixmap, Pixmap);
  168.  
  169. /*  Set the forground pixmap, changing it in place */
  170. void PwRegionSetRawPixmap(Widget, Pixmap);
  171.  
  172. /*  Make sure the image isn't connected to the background */
  173. void PwRegionTear(Widget);
  174.  
  175. /*  Get a copy of the current image & mask, True if exist */
  176. Boolean PwRegionGet(Widget, Pixmap *, Pixmap *);
  177. /*  Get the pixmap id of the current region image */
  178. Pixmap PwGetRawPixmap(Widget);
  179.  
  180. /*  Set the current transformation matrix */
  181. void PwRegionSetMatrix(Widget, pwMatrix);
  182. /*  Append a transformation matrix to the current transform */
  183. void PwRegionAppendMatrix(Widget, pwMatrix);
  184.  
  185. /* Append the current values to the scale */
  186. void PwRegionAddScale(Widget, float *, float *);
  187. /* Set the current X & Y scale values */
  188. void PwRegionSetScale(Widget, float *, float *);
  189.  
  190. /* Reset both the rotation and scale back to identity */
  191. void PwRegionReset(Widget, Boolean);
  192.  
  193. /*  Clear the region to the current background color */
  194. void PwRegionClear(Widget);
  195.  
  196. /*  Turn of the selected region, flag == True for all widgets */
  197. void PwRegionFinish(Widget, Boolean);
  198.  
  199. typedef Pixmap    (*pwRegionDoneProc)(Widget, XImage *, pwMatrix);
  200. void PwRegionSetDone(Widget, pwRegionDoneProc);
  201.  
  202.  
  203. #endif /* _Paint_h */
  204.